import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
import { viteMockServe } from 'vite-plugin-mock'

// https://vite.dev/config/
export default defineConfig(({mode}) => {
  const env = loadEnv(mode, '', '');
  return {
    plugins: [
      react(),
      viteMockServe({
        // 启用mock
        enable: env.VITE_ENABLE_MOCK === 'true',
        // 指向mock文件夹
        mockPath: './src/mock',
        // 自动加载mock文件
        watchFiles: true
      })
    ]
  }
})
